package com.itheima.info.manage.sysytem.dao;

import com.itheima.info.manage.sysytem.domain.Teacher;

public class TeacherDao {
    private  static Teacher[]tea=new Teacher[5];
    public static boolean addTeacher(Teacher teacher) {
        int index=-1;
        for (int i = 0; i <tea.length ; i++) {
            Teacher teacher1=tea[i];
            if (teacher1==null){
                index=i;
                break;
            }
        }
        if (index==-1){
            return false;
        }else {
            tea[index]=teacher;
            return true;
        }
    }


    public static Teacher[] findallTeacher() {
        return tea;

    }

    public static void deletaTeacher(String sid) {
        int index=getindex(sid);
        tea[index]=null;

    }
    public static int getindex(String sid){
        int index=-1;
        for (int i = 0; i <tea.length ; i++) {
            Teacher teacher=tea[i];
            if (teacher!=null&teacher.getSid().equals(sid)){
                index=i;
            }
        }
        return index;
    }

    public static void updateTeacher(String sid, Teacher teacher) {
        int index=getindex(sid);
        tea[index]=teacher;

    }
}
